package com.zy.web.controller.bs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zy.entity.bs.Balance;
import com.zy.pojo.query.bs.BalanceQuery;
import com.zy.pojo.vos.common.PageVo;
import com.zy.pojo.vos.common.ResultVo;
import com.zy.service.bs.BalanceService;
import com.zy.web.controller.base.BaseController;
import com.zy.web.utils.ResultUtil;

@RequestMapping("bs/balance")
@Controller
public class BalanceController extends BaseController {

	@Autowired
	private BalanceService balanceService;

	/**
	 * 分页
 	 * 
 	 * @param balanceQuery
	 * @param start
	 * @param limit
	 * @return
	 */
	@RequestMapping("pageBalance")
	@ResponseBody
	public PageVo pageBalance(BalanceQuery balanceQuery, Integer start, Integer limit) {
		return this.balanceService.pageBalance(balanceQuery, start, limit);
	}

	/**
	 * 新增
	 * 
	 * @param balance
	 * @return
	 */
	@RequestMapping(value = "saveBalance", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo saveBalance(Balance balance) {
		try {
			this.balanceService.saveBalance(balance);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}
	
	/**
	 * 更新
	 * 
	 * @param balance
	 * @return
	 */
	@RequestMapping(value = "updateBalance", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo updateBalance(Balance balance) {
		try {
			this.balanceService.updateBalance(balance);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 删除
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "removeBalance", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo removeBalance(long id) {
		try {
			this.balanceService.removeBalance(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 恢复
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "recover", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo recover(long id) {
		try {
			this.balanceService.recover(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

}